<?php

/**
 * 后台普通系统路由
 */
Route::group(['namespace' => 'Admin', 'prefix' => 'root'], function () {

    //后台登录界面
    Route::get('/login-page', ['as' => 'admin.login-page', 'uses' => 'AdminController@loginPage']);
    Route::any('/login-act', ['as' => 'admin.login-act', 'uses' => 'AdminController@loginAct']);
    Route::get('/login-exit', ['as' => 'admin.login-exit', 'uses' => 'AdminController@exitAct']);

    //权限过滤后台管理界面(需管理员登陆才可访问的理由)
    Route::group(['prefix' => 'auth', 'middleware' => ['auth_admin']], function () {

        Route::get('/welcome', ['as' => 'admin.welcome', 'uses' => 'WorkerController@welcomePage']);
        //站点信息设置
        Route::get('/setting', ['as' => 'admin.setting', 'uses' => 'SettingController@settingPage']);
        Route::any('/config-save', ['as' => 'admin.config.save', 'uses' => 'SettingController@configSave']);
        Route::any('/login-theme', ['as' => 'admin.login.theme', 'uses' => 'SettingController@loginThemeList']);
        Route::any('/login-theme-act/{key}', ['as' => 'admin.login.theme.act', 'uses' => 'SettingController@loginThemeAct']);

        //会员等级管理
        Route::any('/vips/{slug?}', ['as' => 'admin.vips', 'uses' => 'ModeController@vipsPage']);
        Route::any('/vips-save', ['as' => 'admin.vips.save', 'uses' => 'ModeController@vipsSave']);
        Route::any('/vips-del/{slug}', ['as' => 'admin.vips.del', 'uses' => 'ModeController@vipsDel']);

        //系统注册协议
        Route::any('/protocol', ['as' => 'admin.protocol', 'uses' => 'ContentController@protocolPage']);
        Route::any('/protocol-save', ['as' => 'admin.protocol.save', 'uses' => 'ContentController@protocolSave']);


        //一键测试
        Route::any('/system-test-page', ['as' => 'admin.system.testPage', 'uses' => 'SettingController@systemTestPage']);
        Route::any('/system-test', ['as' => 'admin.system.test', 'uses' => 'SettingController@systemTest']);

        //系统统计
        Route::any('/user-count', ['as' => 'admin.user.count', 'uses' => 'WorkerController@userCount']); //会员统计
        Route::any('/money-statement', ['as' => 'admin.money.statement', 'uses' => 'WorkerController@moneyStatement']); //资金报表

        //提现处理
        Route::any('/withdraw/{flag}/{index?}', ['as' => 'admin.withdraw', 'uses' => 'WorkerController@withdrawPage']);
        Route::any('/withdraw-allow', ['as' => 'admin.withdraw.allow', 'uses' => 'WorkerController@allowWithdraw']);
        Route::any('/withdraw-deny', ['as' => 'admin.withdraw.deny', 'uses' => 'WorkerController@denyWithdraw']);

        //打款申请单管理
        Route::any('/remit/{flag}/{index?}', ['as' => 'admin.remit', 'uses' => 'WorkerController@remitPage']);
        Route::any('/remit-allow', ['as' => 'admin.remit.allow', 'uses' => 'WorkerController@allowRemit']);
        Route::any('/remit-deny', ['as' => 'admin.remit.deny', 'uses' => 'WorkerController@denyRemit']);

        //商品管理
        Route::any('/product/{pro?}', ['as' => 'admin.product', 'uses' => 'ProductController@editPage']);
        Route::any('/pro-save', ['as' => 'admin.product.save', 'uses' => 'ProductController@editSave']);
        Route::any('/products/{flag}/{index?}', ['as' => 'admin.product.list', 'uses' => 'ProductController@productsPage']);
        Route::any('/pro-status/{flag}/{id}', ['as' => 'admin.product.status', 'uses' => 'ProductController@proStatus']);
        Route::any('/orders/{flag}/{index?}', ['as' => 'admin.order', 'uses' => 'ProductController@ordersPage']);
        Route::any('/order-edit/{oid}', ['as' => 'admin.order.edit', 'uses' => 'ProductController@orderEditPage']);
        Route::any('/orders-ship/{id}', ['as' => 'admin.order.ship', 'uses' => 'ProductController@ordersShip']);
        Route::any('/orders-del/{id}', ['as' => 'admin.order.del', 'uses' => 'ProductController@ordersDel']);
        Route::any('/orders-end/{id}', ['as' => 'admin.order.end', 'uses' => 'ProductController@ordersEnd']);

        //账单管理
        Route::any('/bonus-log/{index?}', ['as' => 'admin.bonus', 'uses' => 'WorkerController@bonusLogPage']);
        Route::any('/tran-log/{index?}', ['as' => 'admin.transfer', 'uses' => 'WorkerController@transferLogPage']);
        Route::any('/consume-log/{index?}', ['as' => 'admin.consume', 'uses' => 'WorkerController@consumeLogPage']);
        Route::any('/debit-log/{index?}', ['as' => 'admin.debit.log', 'uses' => 'WorkerController@debitLogPage']);
        Route::any('/debit-page', ['as' => 'admin.debit.page', 'uses' => 'WorkerController@debitPage']);
        Route::any('/debit-act/{flag}', ['as' => 'admin.debit.act', 'uses' => 'WorkerController@debitSave']);

        //会员管理
        Route::any('/users/{flag}/{index?}', ['as' => 'admin.users', 'uses' => 'UserController@usersPage']);
        Route::any('/user-edit/{id?}', ['as' => 'admin.users.edit', 'uses' => 'UserController@usersEditPage']);
        Route::any('/user-save/{id?}', ['as' => 'admin.users.save', 'uses' => 'UserController@usersSave']);
        Route::any('/reg-user', ['as' => 'admin.reg', 'uses' => 'UserController@userRegPage']);
        Route::any('/reg-save', ['as' => 'admin.reg.save', 'uses' => 'UserController@regUserSave']);
//        升级会员
        Route::any('/vip-up', ['as' => 'admin.vipup', 'uses' => 'UserController@vipUpPage']);
        Route::any('/vip-up/save', ['as' => 'admin.vipup.save', 'uses' => 'UserController@vipUpSave']);
        Route::any('/del-user/{id}', ['as' => 'admin.user.del', 'uses' => 'UserController@userDel']);
        Route::any('/act-user/{id}/{in_token?}', ['as' => 'admin.active.user', 'uses' => 'UserController@adminActiveUser']);
        Route::any('/act-bdzx/{id}', ['as' => 'admin.active.bdzx', 'uses' => 'UserController@openBdzx']);
        Route::any('/freeze/{id}/{status}', ['as' => 'admin.user.freeze', 'uses' => 'UserController@freezeUser']);
        Route::any('/stop/{id}/{status}', ['as' => 'admin.user.stop', 'uses' => 'UserController@stopUser']);
        Route::any('/go/{id}', ['as' => 'admin.go', 'uses' => 'UserController@goUser']);
        Route::any('/info', ['as' => 'admin.info', 'uses' => 'UserController@userInfo']);
        Route::any('/info-edit/{id?}', ['as' => 'admin.user_info.edit', 'uses' => 'UserController@userInfoEditPage']);
        Route::any('/info-save/{id?}', ['as' => 'admin.user_info.save', 'uses' => 'UserController@userInfoSave']);
        Route::any('/info-off/{id?}', ['as' => 'admin.user_info.off', 'uses' => 'UserController@userInfoOff']);
        Route::any('/info-on/{id}', ['as' => 'admin.user_info.on', 'uses' => 'UserController@userInfoOn']);
        Route::any('/info-del/{id}', ['as' => 'admin.user_info.del', 'uses' => 'UserController@userInfoDel']);

        //系谱图与关系图管理
        Route::any('/node-tree/{id?}', ['as' => 'admin.node.tree', 'uses' => 'UserController@nodeTreePage']);
        Route::any('/node-zTree/{id?}', ['as' => 'admin.node.zTree', 'uses' => 'UserController@zTreePage']);

        //报单中心管理
        Route::any('/bdzx/{flag}', ['as' => 'admin.apply.bdzx', 'uses' => 'UserController@applyBdzxPage']);
        Route::any('/allow-bdzx', ['as' => 'admin.bdzx.allow', 'uses' => 'UserController@allowBdzx']);
        Route::any('/deny-bdzx', ['as' => 'admin.bdzx.deny', 'uses' => 'UserController@denyBdzx']);

        //文章分类管理
        Route::any('/classify', ['as' => 'admin.classify', 'uses' => 'ContentController@classifyPage']);
        Route::any('/classify-edit/{id?}', ['as' => 'admin.classify.edit', 'uses' => 'ContentController@classifyEditPage']);
        Route::any('/classify-save/{id?}', ['as' => 'admin.classify.save', 'uses' => 'ContentController@classifySave']);
        Route::any('/classify-del/{id?}', ['as' => 'admin.classify.del', 'uses' => 'ContentController@classifyDel']);

        //文章管理
        Route::any('/news/{index?}', ['as' => 'admin.news', 'uses' => 'ContentController@newsPage']);
        Route::any('/news-edit/{id?}', ['as' => 'admin.news.edit', 'uses' => 'ContentController@newsEditPage']);
        Route::any('/news-save/{id?}', ['as' => 'admin.news.save', 'uses' => 'ContentController@newSave']);
        Route::any('/news-del/{id?}', ['as' => 'admin.news.del', 'uses' => 'ContentController@newsDel']);

        //公告管理
        Route::any('/notices/{index?}', ['as' => 'admin.notices', 'uses' => 'ContentController@noticesPage']);
        Route::any('/notices-edit/{id?}', ['as' => 'admin.notices.edit', 'uses' => 'ContentController@noticesEditPage']);
        Route::any('/notices-save/{id?}', ['as' => 'admin.notices.save', 'uses' => 'ContentController@noticesSave']);
        Route::any('/notices-del/{id?}', ['as' => 'admin.notices.del', 'uses' => 'ContentController@noticesDel']);

        //碎片分类管理
        Route::any('/slug-classify', ['as' => 'admin.slug.classify', 'uses' => 'SlugController@slugClassifyPage']);
        Route::any('/slug-classify-edit/{id?}', ['as' => 'admin.slugClassify.edit', 'uses' => 'SlugController@slugClassifyEditPage']);
        Route::any('/slug-classify-save/{id?}', ['as' => 'admin.slugClassify.save', 'uses' => 'SlugController@slugClassifySave']);
        Route::any('/slug-classify-del/{id?}', ['as' => 'admin.slugClassify.del', 'uses' => 'SlugController@slugClassifyDel']);

        //碎片内容管理
        Route::any('/slug/{cid?}/{index?}', ['as' => 'admin.slug', 'uses' => 'SlugController@slugPage']);
        Route::any('/slug-edit/{id?}/{cid?}', ['as' => 'admin.slug.edit', 'uses' => 'SlugController@slugEditPage']);
        Route::any('/slug-save/{id?}', ['as' => 'admin.slug.save', 'uses' => 'SlugController@slugSave']);
        Route::any('/slug-del/{id?}', ['as' => 'admin.slug.del', 'uses' => 'SlugController@slugDel']);

        //会员咨询
        Route::any('/feedback/{flag?}/{index?}', ['as' => 'admin.feedback', 'uses' => 'ContentController@feedbackPage']);
        Route::any('/feed-edit/{id}/{index?}', ['as' => 'admin.feedback.edit', 'uses' => 'ContentController@feedbackEditPage']);
        Route::any('/feed-reply/{id}', ['as' => 'admin.feedback.reply', 'uses' => 'ContentController@feedbackReply']);
        Route::any('/feed-del/{id}', ['as' => 'admin.feedback.del', 'uses' => 'ContentController@feedbackDel']);

        //模式管理
        Route::any('/mode-page', ['as' => 'admin.mode', 'uses' => 'ModeController@settingPage']);
        Route::any('/mode-save', ['as' => 'admin.mode.save', 'uses' => 'ModeController@settingSave']);

        //对公账户设置
        Route::any('/receipt-page', ['as' => 'admin.receipt', 'uses' => 'ModeController@receiptSettingPage']);
//        Route::any('/virtual-page', ['as' => 'admin.virtual', 'uses' => 'ModeController@virtualSettingPage']);
        Route::any('/receipt-save', ['as' => 'admin.receipt.save', 'uses' => 'ModeController@receiptSettingSave']);

        //会员升级配置
        Route::any('/vip_config_page', ['as' => 'admin.vip.config', 'uses' => 'ModeController@vipConfigPage']);
        Route::any('/vip_config_edit/{id?}', ['as' => 'admin.vip.config.edit', 'uses' => 'ModeController@vipConfigEdit']);
        Route::any('/vip_config_del/{id?}', ['as' => 'admin.vip.config.del', 'uses' => 'ModeController@vipConfigDel']);
        Route::any('/vip_config_save/{id?}', ['as' => 'admin.vip.config.save', 'uses' => 'ModeController@vipConfigSave']);

        //功能开关管理
        Route::any('/system-switch', ['as' => 'admin.switch', 'uses' => 'ModeController@systemSwitch']);
        //系统邮箱管理
        Route::any('/email-setting', ['as' => 'admin.email', 'uses' => 'ModeController@emailSettingPage']);

        //一键初始化
        Route::any('/initial-page', ['as' => 'admin.initial', 'uses' => 'SettingController@initialPage']);
        Route::any('/initial-act', ['as' => 'admin.initial.act', 'uses' => 'SettingController@initialAct']);
        
        //管理员管理
        Route::get('/admins', ['as' => 'admin.admins', 'uses' => 'AdminController@adminsPage']);
        Route::any('/admins-edit/{id?}', ['as' => 'admin.admins.edit', 'uses' => 'AdminController@adminsEditPage']);
        Route::any('/admins-save/{id?}', ['as' => 'admin.admins.save', 'uses' => 'AdminController@adminsSave']);
        Route::any('/admins-del/{id?}', ['as' => 'admin.admins.del', 'uses' => 'AdminController@adminDel']);

        //角色管理
        Route::get('/roles', ['as' => 'admin.roles', 'uses' => 'AdminController@rolesPage']);
        Route::get('/roles-edit/{id?}', ['as' => 'admin.roles.edit', 'uses' => 'AdminController@rolesEditPage']);
        Route::any('/roles-save/{id?}', ['as' => 'admin.roles.save', 'uses' => 'AdminController@rolesSave']);
        Route::any('/roles-del/{id?}', ['as' => 'admin.roles.del', 'uses' => 'AdminController@rolesDel']);

        //日志记录
        Route::get('/logs/{index?}', ['as' => 'admin.logs', 'uses' => 'SettingController@logsPage']);
        Route::any('/logs-del/{id?}', ['as' => 'admin.logs.del', 'uses' => 'SettingController@logsDel']);

        //数据导出
        Route::any('/export', ['as' => 'admin.export', 'uses' => 'FileController@exportPage']);
        Route::any('/export-act', ['as' => 'admin.export.act', 'uses' => 'FileController@exportUsers']);
        Route::any('/download/{key?}', ['as' => 'admin.download', 'uses' => 'FileController@downFile']);
        Route::any('/delete/{key?}', ['as' => 'admin.delete', 'uses' => 'FileController@delFile']);
        Route::any('/sqls', ['as' => 'admin.sqls', 'uses' => 'FileController@sqlsPage']);
        Route::any('/sql-act', ['as' => 'admin.sqls.bak', 'uses' => 'FileController@sqlBakAct']);
    });
});

/**
 * 管理员操作后台API接口路由
 */
Route::group(['namespace' => 'Safe', 'prefix' => 'safe/api'], function () {

    //获取验证码接口
    Route::get("/g/get-code", 'CommonController@getYzmCode');

    //登录验证接口
    Route::post("/p/login", 'AdminController@loginAct');

    //

});

/**
 * 系统管理后台API接口路由
 */
Route::group(['namespace' => 'Safe', 'prefix' => 'safe/api'], function () {

    //系统操作日志查看接口
    Route::get("g/sys-logs", 'AdminController@loginAct');

});